package com.sgb.jicai.view.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sgb.jicai.R;
import com.sgb.jicai.entity.JiCaiJoinInQuotedPriceCompanyEntity;
import com.swgk.core.BR;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

/**
 * 加盟集采、参与报价  页面的 报价列表和加盟列表  适配器
 */
public class PurConListAdapter extends BaseRecycleAdapter<JiCaiJoinInQuotedPriceCompanyEntity.RecordsDataEntity> {
    private Context context;

    public PurConListAdapter(Context context, List<JiCaiJoinInQuotedPriceCompanyEntity.RecordsDataEntity> datas) {
        super(context, R.layout.item_pur_con_list, datas);
        this.context = context;
    }

    @Override
    public void convert(ItemViewHolder holder, JiCaiJoinInQuotedPriceCompanyEntity.RecordsDataEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        TextView tvparam = holder.itemView.findViewById(R.id.specifications_models);//规格型号
        LinearLayout llgoods = holder.itemView.findViewById(R.id.ll_goods);//规格型号
        if (entity.getGroupbuyClass()==1){
            llgoods.setVisibility(View.VISIBLE);
        }else {
            llgoods.setVisibility(View.GONE);
        }
        if (entity.getAttrlist()!=null&&entity.getAttrlist().size()>0){
            StringBuilder stringattr = new StringBuilder();
            for (JiCaiJoinInQuotedPriceCompanyEntity.AttrlistEntity attrBean : entity.getAttrlist()) {
                if (!TextUtils.isEmpty(attrBean.getValue())){
                    stringattr.append(attrBean.getName()).append(":").append(attrBean.getValue()).append(" ");
                }
            }
            if (!TextUtils.isEmpty(stringattr.toString())){
                tvparam.setText(stringattr.toString());
            }else {
                tvparam.setText("无");
            }
        }else {
            tvparam.setText("无");
        }

    }

}
